package com.bullsora.kindlerss.business;


import com.bullsora.kindlerss.model.FeedEntry;
import com.bullsora.kindlerss.model.FeedUrl;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

public class FeedServiceImpl implements FeedService {

  @Override
  public List<FeedEntry> findNewEntriesForUrl(Date since, FeedUrl url) {
    return FeedEntry.findNewEntriesForUrl(since, url);
  }

  @Override
  public void removeFeedEntriesReceivedBefore(int daysThreshold) {
    Calendar calendar = new GregorianCalendar();
    calendar.add(Calendar.DAY_OF_MONTH, -daysThreshold);

    FeedEntry.removeFeedEntriesReceivedBefore(calendar.getTime());
  }

  @Override
  public boolean existsEntryForFeedUrlWithLink(FeedUrl feedUrl, String link) {
    return FeedEntry.existsEntryForFeedUrlWithLink(feedUrl, link);
  }
}
